package Servlet.Manager;

import Dao.DeleteBookDao;
import Dao.DeleteBorrowBookDao;
import Dao.DeleteUserBorrowBookDao;
import Dao.DeleteUserDao;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/managerDeleteUserServlet")
public class ManagerDeleteUserServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        //删除user表的数据
        DeleteUserDao.DeleteUser(Integer.parseInt(id));
        //删除borrowbook表的数据
        DeleteUserBorrowBookDao.DeleteBorrowBook(Integer.parseInt(id));
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }
}
